<?php

require_once('../domain/Saison.php');

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of SaisonSelection
 *
 * @author riemerb
 */
class SaisonSelection {
    private
        $saisons,
        $selected;

    public function __construct($saisons = null) 
    {
        $this->saisons = $saisons;
        $this->selected = 0/*count($saisons)-1*/;
    }
   
    public function setSelectedIndex($selected){
        if (count($this->saisons)-1 >= $selected && 0 <= $selected){
            $this->selected = $selected;        
        }
    }

    public function setSelectedSaison($selected){
        $length = count($this->saisons)-1;
        for ($i = 0; $i <= $length; $i++) {
            $saison = $this->saisons[$i];
            if ((strcmp($saison->getBeginn(), $selected->getBeginn()) == 0)
                && (strcmp($saison->getEnde(), $selected->getEnde()) == 0)
            ) {
                $this->selected = $i;
                break;
            }
        }
    }

    public function getSelectedIndex(){
        return $this->selected;
    }
    
    public function getSaisons(){
        return $this->saisons;
    }
    
    public function getSelectedSaisons(){
        return $this->saisons[$this->selected];
    }

}
